--File ： ChapterView.lua
--Author : zee
--Date   : 2015/4/8
--Description : 主界面，从scene来，用于组织所有的layer，层级等等。




RankNode = class("RankNode",function()
    -- 继承
    local ret = cc.Layer:create()

    ret.start = nil
    return ret
end)

RankNode.__index = RankNode


function RankNode:create()
    local ret = RankNode:new()
    return ret
end




--------------------------------------------------------
-- 初始化
--------------------------------------------------------
function RankNode:start()
    -- 
    self:makeUI()
end




function RankNode:makeUI()
    self.rootNode = cc.CSLoader:createNode("csb/start/rankNode.csb")
    self:addChild( self.rootNode )

    local function clickFullEvt(btn) 
        Sound(9)
        self:removeFromParent()
    end
    self.btn_lay = SearchChildByName( self.rootNode, "lay" )
    self.btn_lay:addClickEventListener( clickFullEvt )
    
    -- 
    self.ary_rankItem = {}
    for i=1,6 do 
        self.ary_rankItem[i] = RankItem:create()
        self.ary_rankItem[i]:bindToBode( SearchChildByName( self.rootNode, "rank_"..i ) )
    end
    --
    local data = PlayRankData:getInstance().existRank
    for i=1,6 do 
        if( data[i]~=nil ) then 
            local score = data[i].score
            local name = data[i].name
            local time = data[i].time
            self.ary_rankItem[i]:setInfo( i, score, name, time )
        else 
            self.ary_rankItem[i]:setInfo( nil )
        end
    end
end






